import React from "react";

// eslint-disable-next-line import/no-anonymous-default-export
export default class extends React.Component {

    // 第二种初始化方法
    state = {
        count: 1
    };


    onIncrement(){
        console.log("事件处理程序中的this:" + this);
        this.setState({count:this.state.count + 1})
    }

    render() {
        return (
            <div>
                <div>计数器:{this.state.count}</div>
                <button onClick={() => this.onIncrement()}> +1</button>
            </div>
        )
    }
}